home *** CD-ROM | disk | FTP | other *** search
- ; in 7, 10
-
- include "src:shadowlord.i"
-
- ; V1.01
- ; Added bigger understanding of PC box characters.
- ; Now also understands one-wide box chars, and thick corner changed to #,
- ; single corner to +.
-
- ; V1.02
- ; Added bad mode error, and error on no space between mode and the rest.
-
- ; V1.10
- ; Added cut endspace.
- ; Added text output.
-
- * 05-Feb-93
- * 10 days of hard coding
-
- ; during the program
- ; a0=source
- ; a1=dest
- ; a2=spacebuf
-
- ; d0=current char
- ; d1=load counter
- ; d2=savebyte counter
-
- testmode = 1
-
- if testmode=1
- lea test_comline,a0
- move.l #test_len,d0
- endc
-
- progstart:
- clr.b -1(a0,d0.l)
- move.l a0,commandstart
- move.w d0,commandlen
- add.l d0,a0
- subq.l #1,a0
- move.l a0,commandend
-
- lea dosname,a1
- moveq #0,d0
- move.l execbase,a6
- jsr openlibrary(a6)
- move.l d0,dosbase
-
- move.l dosbase,a6
- jsr output(a6)
- move.l d0,outstruct
-
- move.l #text_cursoroff,d2
- moveq #5,d3
- bsr printtext
-
- move.l commandstart,a0
- tst.b (a0) ; if blank commandline, instructions
- beq credits
- cmp.b #"?",(a0)
- beq credits
- cmp.b #"-",(a0)
- beq checkoption
-
- parse:
- cmp.b #" ",1(a0) ; at least one space after option
- bne err_nocomlinespace
- cmp.b #"p",(a0)
- beq frompcmode
- cmp.b #"P",(a0)
- beq topcmode
- cmp.b #"s",(a0)
- beq fromsf7mode
- cmp.b #"S",(a0)
- beq tosf7mode
- bra err_badmode
-
- checkoption:
- cmp.b #"n",1(a0)
- beq opt_nocutspace
- bra err_badcomline
-
- opt_nocutspace:
- clr.b mode_cutspace
- addq.l #2,a0
- cmp.b #" ",(a0)
- bne err_badcomline
- bsr skipspace
- bra parse
-
- frompcmode:
- move.b #1,mode
- bra nameparse
-
- fromsf7mode:
- move.b #2,mode
- bra nameparse
-
- tosf7mode:
- move.b #-2,mode
- bra nameparse
-
- topcmode:
- move.b #-1,mode
- bra nameparse
-
- nameparse:
- addq.l #1,a0
- bsr skipspace
- cmp.l #0,a0
- beq err_badcomline
- move.l a0,sourcenamestart
- bsr findend
- cmp.l #0,a0
- beq err_badcomline
- move.l a0,sourcenameend
- addq.l #1,a0
- sub.l sourcenamestart,a0
- move.l a0,sourcenamelen
-
- move.l sourcenamestart,a0
- move.l #sourcename,a1
- move.l sourcenamelen,d0
- subq.l #1,d0
- cmp.b #'"',(a0)
- beq removequotes
-
- copysourcename:
- move.b (a0)+,(a1)+
- dbf d0,copysourcename
- clr.b (a1)
-
- move.l sourcenameend,a0
- addq.l #1,a0
- cmp.l commandend,a0
- beq nodest
-
- bsr skipspace
- cmp.l #0,a0
- beq err_badcomline
- move.l a0,destnamestart
- bsr findend
- cmp.l #0,a0
- beq err_badcomline
- move.l a0,destnameend
- addq.l #1,a0
- sub.l destnamestart,a0
- move.l a0,destnamelen
- move.l a0,d0
-
- move.l destnamestart,a0
- move.l #destname,a1
- subq.l #1,d0
- cmp.b #'"',(a0)
- beq removequotes1
-
- copydestname:
- move.b (a0)+,(a1)+
- dbf d0,copydestname
- bra openfiles
-
- removequotes:
- addq.l #1,a0
- subq.l #2,d0
- bra copysourcename
-
- removequotes1:
- addq.l #1,a0
- subq.l #2,d0
- bra copydestname
-
- removequotes2:
- addq.l #1,a0
- subq.l #2,d0
- bra copydestname1
-
- nodest:
- move.l #destname,a1
- move.l sourcenamestart,a0
- move.l sourcenamelen,d0
- subq.l #1,d0
- cmp.b #'"',(a0)
- beq removequotes2
-
- copydestname1:
- move.b (a0)+,(a1)+
- dbf d0,copydestname1
-
- cmp.b #-1,mode
- beq pcsuffix
- cmp.b #-2,mode
- beq sf7suffix
-
- amigasuffix:
- lea text_amigasuf,a0
- moveq #4-1,d0
-
- amigasuffix1:
- move.b (a0)+,(a1)+
- dbf d0,amigasuffix1
- bra openfiles
-
- pcsuffix:
- lea text_pcsuf,a0
- moveq #3-1,d0
-
- pcsuffix1:
- move.b (a0)+,(a1)+
- dbf d0,pcsuffix1
- bra openfiles
-
- sf7suffix:
- lea text_sf7suf,a0
- moveq #4-1,d0
-
- sf7suffix1:
- move.b (a0)+,(a1)+
- dbf d0,sf7suffix1
-
- openfiles:
- clr.b (a1) ; end of filename
- move.l #sourcename,d1
- move.l #1005,d2
- move.l dosbase,a6
- jsr open(a6)
- tst.l d0
- beq err_nosource
- move.l d0,sourcehandle
-
- move.l #destname,d1
- move.l #1006,d2
- move.l dosbase,a6
- jsr open(a6)
- tst.l d0
- beq err_nodest
- move.l d0,desthandle
-
- readblock:
- move.l sourcehandle,d1
- move.l #sourcebuf,d2
- move.l #1024,d3
- move.l dosbase,a6
- jsr read(a6)
- add.l d0,readbytes
- move.l d0,d1
- beq closefiles ; readbytes=0 - quit
- subq.l #1,d1
- moveq #0,d2
-
- lea sourcebuf,a0
- lea destbuf,a1
-
- morecharacters:
- move.b (a0)+,d0
- bra cutspace
-
- checknormal:
- cmp.b #-2,mode
- beq tosf7
- cmp.b #-1,mode
- beq topc
- cmp.b #2,mode
- beq fromsf7
-
- frompc:
- cmp.b #$84,d0
- beq ami_lowae
- cmp.b #$94,d0
- beq ami_lowoe
- cmp.b #$8e,d0
- beq ami_upae
- cmp.b #$99,d0
- beq ami_upoe
- cmp.b #13,d0
- beq nochar
- cmp.b #0,d0
- beq nochar
- cmp.b #$1a,d0 ; ctrl+z
- beq nochar
- cmp.b #$c9,d0
- beq ami_bigcorner
- cmp.b #$bb,d0
- beq ami_bigcorner
- cmp.b #$c8,d0
- beq ami_bigcorner
- cmp.b #$bc,d0
- beq ami_bigcorner
- cmp.b #$cd,d0
- beq ami_doubleline
- cmp.b #$ba,d0
- beq ami_upline
- cmp.b #$b3,d0
- beq ami_upline
- cmp.b #$b0,d0
- beq ami_box
- cmp.b #$b1,d0
- beq ami_box
- cmp.b #$b2,d0
- beq ami_box
- cmp.b #$c4,d0
- beq ami_singleline
- cmp.b #$c0,d0
- beq ami_smallcorner
- cmp.b #$d9,d0
- beq ami_smallcorner
- cmp.b #$bf,d0
- beq ami_smallcorner
- cmp.b #$da,d0
- beq ami_smallcorner
-
- nextchar:
- move.b d0,(a1)+
- addq.l #1,d2
-
- nochar:
- dbf d1,morecharacters
-
- move.l desthandle,d1
- move.l d2,d3
- add.l d2,writtenbytes
- move.l #destbuf,d2
- move.l dosbase,a6
- jsr write(a6)
-
- move.l #text_input,d2
- moveq #15,d3
- bsr printtext
-
- lea numberbuf,a0
- move.l readbytes,d0
- bsr num2ascii
-
- move.l a0,d2
- move.l d0,d3
- bsr printtext
-
- move.l #text_output,d2
- moveq #18,d3
- bsr printtext
-
- lea numberbuf,a0
- move.l writtenbytes,d0
- bsr num2ascii
-
- move.l a0,d2
- move.l d0,d3
- bsr printtext
-
- move.l #text_cr,d2
- moveq #1,d3
- bsr printtext
-
- bra readblock
-
- cutspace:
- move.l spacepointer,a2
- cmp.b #" ",d0
- beq addspace
- cmp.b #9,d0 ; tab
- beq addspace
-
- cmp.b #1,mode_cutspace
- bne cutspace1
-
- cmp.b #10,d0 ; lf
- beq cutspaces
- cmp.b #13,d0 ; cr
- beq cutspaces
-
- cutspace1:
- tst.l spacenumber
- bne linkspaces
- bra checknormal
-
- addspace:
- addq.l #1,spacenumber
- move.b d0,(a2)+
- move.l a2,spacepointer
- bra nochar
-
- cutspaces:
- clr.l spacenumber
- move.l #spacebuf,spacepointer
- bra checknormal
-
- linkspaces:
- move.l spacenumber,d3
- add.l d3,d2
- subq.l #1,d3
- lea spacebuf,a2
-
- linkspaces1:
- move.b (a2)+,(a1)+
- dbf d3,linkspaces1
- clr.l spacenumber
- move.l #spacebuf,spacepointer
- bra checknormal
-
- topc:
- cmp.b #"ä",d0
- beq pc_lowae
- cmp.b #"ö",d0
- beq pc_lowoe
- cmp.b #"Ä",d0
- beq pc_upae
- cmp.b #"Ö",d0
- beq pc_upoe
- cmp.b #10,d0
- beq addcr
- cmp.b #0,d0
- beq nochar
- cmp.b #$1a,d0 ; ctrl+z
- beq nochar
- bra nextchar
-
- fromsf7:
- cmp.b #"{",d0
- beq ami_lowae
- cmp.b #"|",d0
- beq ami_lowoe
- cmp.b #"[",d0
- beq ami_upae
- cmp.b #"\",d0
- beq ami_upoe
- cmp.b #13,d0
- beq nochar
- cmp.b #0,d0
- beq nochar
- cmp.b #$1a,d0 ; ctrl+z
- beq nochar
- bra nextchar
-
- tosf7:
- cmp.b #"ä",d0
- beq sf7_lowae
- cmp.b #"ö",d0
- beq sf7_lowoe
- cmp.b #"Ä",d0
- beq sf7_upae
- cmp.b #"Ö",d0
- beq sf7_upoe
- cmp.b #10,d0
- beq addcr
- cmp.b #0,d0
- beq nochar
- cmp.b #$1a,d0 ; ctrl+z
- beq nochar
- bra nextchar
-
- ami_singleline:
- move.b #"-",d0
- bra nextchar
-
- ami_box:
- move.b #$7f,d0
- bra nextchar
-
- ami_upline:
- move.b #"|",d0
- bra nextchar
-
- ami_doubleline:
- move.b #"=",d0
- bra nextchar
-
- ami_smallcorner:
- move.b #"+",d0
- bra nextchar
-
- ami_bigcorner:
- move.b #"#",d0
- bra nextchar
-
- ami_lowae:
- move.b #"ä",d0
- bra nextchar
-
- ami_lowoe:
- move.b #"ö",d0
- bra nextchar
-
- ami_upae:
- move.b #"Ä",d0
- bra nextchar
-
- ami_upoe:
- move.b #"Ö",d0
- bra nextchar
-
- pc_lowae:
- move.b #$84,d0
- bra nextchar
-
- pc_lowoe:
- move.b #$94,d0
- bra nextchar
-
- pc_upae:
- move.b #$8e,d0
- bra nextchar
-
- pc_upoe:
- move.b #$99,d0
- bra nextchar
-
- sf7_lowae:
- move.b #"{",d0
- bra nextchar
-
- sf7_lowoe:
- move.b #"|",d0
- bra nextchar
-
- sf7_upae:
- move.b #"[",d0
- bra nextchar
-
- sf7_upoe:
- move.b #"\",d0
- bra nextchar
-
- addcr:
- move.b #13,(a1)+
- addq.l #1,d2
- bra nextchar
-
- closefiles:
- move.l sourcehandle,d1
- move.l dosbase,a6
- jsr close(a6)
- move.l desthandle,d1
- move.l dosbase,a6
- jsr close(a6)
- bra endprogram1
-
- credits:
- move.l #text_credits,d2
- move.l #len_credits,d3
- bsr printtext
- bra endprogram1
-
- err_nosource:
- move.l #text_nosource,d2
- moveq #36,d3
- bsr printtext
- bra endprogram1
-
- err_nomemory:
- move.l #text_nomemory,d2
- moveq #26,d3
- bsr printtext
- bra endprogram1
-
- err_badcomline:
- move.l #text_badcomline,d2
- moveq #25,d3
- bsr printtext
- bra endprogram1
-
- err_nodest:
- move.l #text_nodest,d2
- moveq #41,d3
- bsr printtext
- bra endprogram2
-
- err_badmode:
- move.l #text_badmode,d2
- moveq #32,d3
- bsr printtext
- bra endprogram1
-
- err_nocomlinespace:
- move.l #text_nocomlinespace,d2
- moveq #60,d3
- bsr printtext
- bra endprogram1
-
- endprogram1:
- move.l #text_cursoron,d2
- moveq #6,d3
- bsr printtext
-
- move.l execbase,a6
- move.l dosbase,a1
- jsr closelibrary(a6)
- moveq #0,d0
- rts
-
- endprogram2:
- move.l sourcehandle,d1
- move.l dosbase,a6
- jsr close(a6)
- bra endprogram1
-
- **********
- ** SUBS **
- **********
-
- printtext:
- if testmode=1
- rts
- endc
- move.l outstruct,d1
- move.l dosbase,a6
- jsr write(a6)
- rts
-
- skipspace:
- cmp.b #" ",(a0)
- beq skipspace1
- rts
-
- skipspace1:
- add.l #1,a0
- cmp.l commandend,a0
- bcs skipspace
- move.l #0,a0
- rts
-
- findend:
- cmp.b #'"',(a0)
- beq findend_quote
-
- findend_space:
- addq.l #1,a0
- cmp.b #" ",(a0)
- beq findend_space1
- cmp.b #0,(a0)
- beq findend_space1
- cmp.l commandend,a0
- bls findend_space
- move.l #0,a0
- rts
-
- findend_space1:
- subq.l #1,a0
- rts
-
- findend_quote:
- addq.l #1,a0
- cmp.b #'"',(a0)
- bne findend_quote1
- rts
-
- findend_quote1:
- cmp.l commandend,a0
- bls findend_quote
- move.l #0,a0
- rts
-
- num2ascii:
- clr.l d1
- move.l a0,a1
-
- num2ascii1:
- cmp.l #1000000000,d0
- bcc onegig
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii2:
- cmp.l #100000000,d0
- bcc one100meg
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii3:
- cmp.l #10000000,d0
- bcc one10meg
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii4:
- cmp.l #1000000,d0
- bcc onemeg
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii5:
- cmp.l #100000,d0
- bcc one100k
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii6:
- cmp.l #10000,d0
- bcc one10k
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii7:
- cmp.l #1000,d0
- bcc onek
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii8:
- cmp.l #100,d0
- bcc one100
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii9:
- cmp.l #10,d0
- bcc one10
- move.b d1,(a0)
- add.b #"0",(a0)+
- clr.l d1
-
- num2ascii10:
- move.b d0,(a0)
- add.b #"0",(a0)
- move.l a1,a0
-
- num2ascii11:
- cmp.b #"0",(a0)
- beq num2ascii_clearzero
-
- move.l a1,a0
- moveq #10,d0
-
- num2ascii12:
- cmp.b #" ",(a0)
- beq num2ascii_sublen
- rts
-
- num2ascii_sublen:
- subq.l #1,d0
- add.l #1,a0
- bra num2ascii12
-
- num2ascii_clearzero:
- move.b #" ",(a0)+
- bra num2ascii11
-
- onegig:
- sub.l #1000000000,d0
- addq.l #1,d1
- bra num2ascii1
-
- one100meg:
- sub.l #100000000,d0
- addq.l #1,d1
- bra num2ascii2
-
- one10meg:
- sub.l #10000000,d0
- addq.l #1,d1
- bra num2ascii3
-
- onemeg:
- sub.l #1000000,d0
- addq.l #1,d1
- bra num2ascii4
-
- one100k:
- sub.l #100000,d0
- addq.l #1,d1
- bra num2ascii5
-
- one10k:
- sub.l #10000,d0
- addq.l #1,d1
- bra num2ascii6
-
- onek:
- sub.l #1000,d0
- addq.l #1,d1
- bra num2ascii7
-
- one100:
- sub.l #100,d0
- addq.l #1,d1
- bra num2ascii8
-
- one10:
- sub.l #10,d0
- addq.l #1,d1
- bra num2ascii9
-
-
- **********
- ** DATA **
- **********
-
- section fastdata,data
-
- spacepointer:
- dc.l spacebuf
-
- text_credits:
- incbin "src:Port/PortOpts"
-
- text_cursoroff:
- dc.b 27,"[0 p"
-
- text_cursoron:
- dc.b 27,"[1 p",10
-
- text_badcomline:
- dc.b "ERROR! Bad commandline.",10
-
- text_nomemory:
- dc.b "ERROR! Not enough memory.",10
-
- text_badsource:
- dc.b "ERROR! Bad sourcefile.",10
-
- text_nosource:
- dc.b "ERROR! Could not open source file.",10
-
- text_nodest:
- dc.b "ERROR! Could not open destination file.",10
-
- text_badmode:
- dc.b "ERROR! Bad mode specification.",10
-
- text_nocomlinespace:
- dc.b "ERROR! The mode must be separated with at least one space.",10
-
- text_input:
- dc.b 27,"[1mInput: ",27,"[0m"
-
- text_output:
- dc.b 27,"[1m Output: ",27,"[0m"
-
- dosname:
- dc.b "dos.library",0
-
- text_amigasuf:
- dc.b ".AMI"
-
- text_pcsuf:
- dc.b ".PC"
-
- text_sf7suf:
- dc.b ".SF7"
-
- text_cr:
- dc.b 13
-
- mode_cutspace:
- dc.b 1
-
- if testmode=1
-
- test_comline:
- dc.b "p dh1:text/k-18/megatext2 dh1:text/k-18/megatext3",10
-
- test_comlineend:
-
- test_len = test_comlineend-test_comline
- endc
-
- section fastblank,bss
-
- writtenbytes:
- ds.l 1
-
- readbytes:
- ds.l 1
-
- sourcehandle:
- ds.l 1
-
- desthandle:
- ds.l 1
-
- outstruct:
- ds.l 1
-
- destnamestart:
- ds.l 1
-
- destnameend:
- ds.l 1
-
- destnamelen:
- ds.l 1
-
- sourcenamestart:
- ds.l 1
-
- sourcenameend:
- ds.l 1
-
- sourcenamelen:
- ds.l 1
-
- commandstart:
- ds.l 1
-
- commandend:
- ds.l 1
-
- commandlen:
- ds.l 1
-
- dosbase:
- ds.l 1
-
- spacenumber:
- ds.l 1
-
- mode:
- ds.b 1
-
- sourcename:
- ds.b 256
-
- destname:
- ds.b 256
-
- sourcebuf:
- ds.b 1024
-
- destbuf:
- ds.b 2048
-
- spacebuf:
- ds.b 1024
-
- numberbuf:
- ds.b 10
-
- len_credits = text_cursoroff-text_credits
-